package br.com.cicero.designpatterns.command.absfactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import br.com.cicero.designpatterns.command.BaseCommand;

public class AplicativoComAbstractFactory {
	
	private CommandFactory commandFactory;
	
	private void initCommandFactory() throws IOException, ClassNotFoundException, 
	    InstantiationException, IllegalAccessException {
		
		Properties propriedades = new Properties();
		InputStream is = getClass().getResourceAsStream("config.properties");
		propriedades.load(is);
		is.close();
		String nome = propriedades.getProperty("command.factory.class");
		Class classeFactoryCommandFactory = Class.forName(nome);
		commandFactory = (CommandFactory) classeFactoryCommandFactory.newInstance();
				
	}
	
	public void buttonEnviar_clicked() {
		
		BaseCommand comandoEnviar = commandFactory.create("EnviarPedido");
		comandoEnviar.executar();
				
	}
	
	public void buttonGerarPDF_clicked() {
		
		BaseCommand comandoGerarPDF = commandFactory.create("GerarPDF");
		comandoGerarPDF.executar();
		
	}
	
}
